{% assign data = section.settings %}

<div class="footer" style="--bg: {{ data.bg_color }};--color: {{ data.font_color }};">
  <div class="footer_top py-[35px]">
    <div class="container_wrapper">
      <div class="content md:flex md:flex-wrap md:justify-between gap-10">
        {% include 'footer_menu', nav_id: data.nav.id %}
        <div class="footer_nwes md:mt-0 mt-[33px]">
          {% if data.email_title != '' %}
            <div class="email_title mb-3 font-bold">{{ data.email_title }}</div>
          {% endif %}
          {% if data.email_detail != '' %}
            <div class="email_detail opacity-80 mb-2.5">{{ data.email_detail|html_content_filter }}</div>
          {% endif %}
          <div class="footer_news_input flex gap-2.5">
            <input
              class="bg-transparent flex-1"
              type="text"
              placeholder="{{ lang.general.email }}"
              id="footer_newsletter_input"
							style="width: 100%;"
            >
            <div
              class="submit_box"
              id="footer_newsletter_btn"
              style="--sub-btn-color: {{data.sub_btn_color}};--sub-btn-bg: {{data.sub_btn_bg}};"
            >
              {{ data.sub_text | default: 'Subscribe' }}
            </div>
          </div>
          <div class="sns_box mt-[35px]">
            {% include 'share_link', color: data.font_color, section: data %}
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="footer_bottom pb-10">
    <div class="container_wrapper">
      <div class="copyright md:text-left text-center">
        {% if data.copyright != '' %}
          <div class="opacity-80">{{ data.copyright | parse_variables|html_content_filter }}</div>
        {% endif %}
      </div>
    </div>
  </div>
</div>

<script>
  $(function () {
    if (moi.isMobile()) {
      $('.oem_footer_menu .mobile_title').on('click', function () {
        $(this).toggleClass('open');
        $(this).parent().find('.list').slideToggle(200);
      });
    }
  });
</script>

<script>
  document.addEventListener('DOMContentLoaded', function () {
    const blockSubmitNewsletter = moi.throttle(function () {
      var domEmail = '#footer_newsletter_input';
      email = $('#footer_newsletter_input').val();
      if (email == '') {
        moi.tooltip({
          placement: 'top',
          el: domEmail,
          timer: 5000,
          space: 0,
          content: '{{ lang.general.please_enter_a_valid_email_address }}',
        });
        return;
      }
      $isvalidemail =
        /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(
          email
        );
      if (!$isvalidemail) {
        moi.tooltip({
          placement: 'top',
          el: domEmail,
          timer: 1000,
          space: 0,
          content: '{{ lang.general.please_enter_a_valid_email_address }}',
        });
        return;
      }
      const load = moi.nodeShowLoading('#footer_newsletter_btn', '{{ section.settings.buttonColor }}');
      moi.ajax({
        url: '/module/newsletter',
        type: 'POST',
        data: JSON.stringify({ email: email }),
        dataType: 'json',
        cache: false,
        complete: function () {
          load.close();
        },
        success: function (res) {
          if (res.data && res.data.data) {
            if (res.data.new_customer) {
              callback_generate_lead();
            }
            moi.message({ content: `{{ section.settings.newsletterTip|html_content_filter }}` });
          } else {
            moi.tooltip({
              placement: 'top',
              el: domEmail,
              timer: 1000,
              space: 0,
              content: '{{ lang.general.subscribe_failed }}',
            });
          }
        },
        error: function () {
          moi.tooltip({
            placement: 'top',
            el: domEmail,
            timer: 1000,
            space: 0,
            content: '{{ lang.general.connection_fails_please_retry_refresh }}',
          });
        },
      });
    }, 3000);
    $('#footer_newsletter_btn').click(function () {
      blockSubmitNewsletter();
    });
    $('#footer_newsletter_input').on('keydown', function (e) {
      if (e.which === 13) {
        blockSubmitNewsletter();
      }
    });
  });
</script>

{% schema %}
{
	"tag": "footer",
	"class": "footer",
	"is_global": true,
	"name": {
		"zh_CN": "底部"
	},
	"max_blocks": "0",
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "菜单导航设置",
				"en_US": "Menu navigation Settings"
			}
		},
		{
			"type": "card_nav",
			"label": {
				"zh_CN": "选择菜单",
				"en_US": "Select menu"
			},
			"default": {
				"id": "",
				"title": ""
			},
			"id": "nav"
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "订阅标题",
				"en_US": "Subscription title"
			},
			"id": "email_title",
			"default": "NEWSLETTER SIGN UP"
		},
		{
			"type": "card_text_editor",
			"label": {
				"zh_CN": "订阅描述",
				"en_US": "Subscription description"
			},
			"id": "email_detail",
			"default": "Sign up for exclusive updates, new arrivals & insider only discounts"
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "订阅按钮文字",
				"en_US": "Subscribe button text"
			},
			"id": "sub_text",
			"default": "SUBMIT"
		},
		{
			"type": "card_textarea",
			"id": "newsletterTip",
			"label": {
				"zh_CN": "订阅成功文字",
				"en_US": "Subscribe successful text"
			},
			"placeholder": {
				"zh_CN": ""
			},
			"default": "Thank you for joining our mailing list!"
		},
		{
			"type": "card_color",
			"label": {
				"zh_CN": "背景颜色",
				"en_US": "Background color"
			},
			"default": "#232323",
			"id": "bg_color"
		},
		{
			"type": "card_color",
			"label": {
				"zh_CN": "字体颜色",
				"en_US": "Font color"
			},
			"default": "#888888",
			"id": "font_color"
		},
		{
			"type": "card_text_editor",
			"label": {
				"zh_CN": "底部版权",
				"en_US": "Copyright at the bottom"
			},
			"id": "copyright",
			"default": "@{{date_year}} {{storeConfig.name}} {{current_domain}}",
			"info": {
				"zh_CN": "<p><a target='_blank' href='https://oemsaas.yuque.com/staff-sbl3ig/clazyz/exmzohc53i16spuo' style='color:#3590e9'>如何配置？</a></p>",
				"en_US": "<p><a target='_blank' href='https://oemsaas.yuque.com/staff-sbl3ig/clazyz/exmzohc53i16spuo' style='color:#3590e9'>How to configure?</a></ p>"
			}
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "SNS账号",
				"en_US": "SNS account"
			}
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Facebook",
				"en_US": "Facebook"
			},
			"id": "is_facebook"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Twitter",
				"en_US": "Twitter"
			},
			"id": "is_twitter"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Pinterest",
				"en_US": "Pinterest"
			},
			"id": "is_pinterest"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Instagram",
				"en_US": "Instagram"
			},
			"id": "is_instagram"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Snapchat",
				"en_US": "SnaPChat"
			},
			"id": "is_snapchat"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Tiktok",
				"en_US": "Tiktok"
			},
			"id": "is_tiktok"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Tumblr",
				"en_US": "Tumblr"
			},
			"id": "is_tumblr"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Linkedin",
				"en_US": "Linkedin"
			},
			"id": "is_linkedin"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Youtube",
				"en_US": "Youtube"
			},
			"id": "is_youtube"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Vimeo",
				"en_US": "Vimeo"
			},
			"id": "is_vimeo"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "VK",
				"en_US": "VK"
			},
			"id": "is_vk"
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "Whatsapp",
				"en_US": "Whatsapp"
			},
			"id": "is_whatsapp"
		},
		{
            "type": "card_switch",
            "label": {
                "zh_CN": "Line",
                "en_US": "Line"
            },
            "id": "is_line"
        }
	],
	"blocks": [],
	"default": {
		"settings": {
			"nav": {
				"id": "",
				"title": ""
			},
			"email_title": "NEWSLETTER SIGN UP",
			"email_detail": "Sign up for exclusive updates, new arrivals &amp; insider only discounts",
			"sub_text": "SUBMIT",
			"newsletterTip": "Thank you for joining our mailing list!",
			"bg_color": "#232323",
			"font_color": "#ffffff",
			"copyright": "@{{ date_year }}{{ storeConfig.name }}{{ current_domain }}",
			"is_facebook": true,
			"is_twitter": true,
			"is_pinterest": true,
			"is_instagram": true,
			"is_snapchat": true,
			"is_tiktok": false,
			"is_tumblr": false,
			"is_linkedin": false,
			"is_youtube": false,
			"is_vimeo": false,
			"is_vk": false,
			"is_whatsapp": false,
			"is_line": false
		},
		"blocks": []
	}
}
{% endschema %}
